/**
 * related to listRowTemplate.ui
 * 
 * @Author : chenglm
 * @Timestamp : 2016-07-26
 */
var root=ui("$");
var common = require("common");
var do_ALayout_base0 = ui("do_ALayout_base0");
var do_ALayout_base1 = ui("do_ALayout_base1");
var do_ALayout_base2 = ui("do_ALayout_base2");
var do_Label_firstType = ui("do_Label_firstType");
var sericeIcon = ui("sericeIcon");
var iconSerice = ["source://image/serice/icon_01.png","source://image/serice/icon_02.png","source://image/serice/icon_03.png"];
var colorSerice = ["1caa3eFF","0a6fb5FF","68278bFF"];
//设置数据绑定的映射关系
root.setMapping({
	"do_Label_firstType.text":"firstType",
	"do_ALayout_base0.tag":"id0",
	"do_ImageView_photosImg0.source":"photosImg0",
	"do_Label_typeStr0.text":"typeStr0",
	"do_Label_realName0.text":"realName0",
	"do_Label_orderedCount0.text":"orderedCount0",
	"do_Label_distanceStr0.text":"distanceStr0",
	"do_Label_title0.text":"title0",
	"starList0.tag":"feedbackScore0",
	
	"do_ALayout_base1.tag":"id1",
	"do_ImageView_photosImg1.source":"photosImg1",
	"do_Label_typeStr1.text":"typeStr1",
	"do_Label_realName1.text":"realName1",
	"do_Label_orderedCount1.text":"orderedCount1",
	"do_Label_distanceStr1.text":"distanceStr1",
	"do_Label_title1.text":"title1",
	"starList1.tag":"feedbackScore1",
	
	"do_ALayout_base2.tag":"id2",
	"do_ImageView_photosImg2.source":"photosImg2",
	"do_Label_typeStr2.text":"typeStr2",
	"do_Label_realName2.text":"realName2",
	"do_Label_orderedCount2.text":"orderedCount2",
	"do_Label_distanceStr2.text":"distanceStr2",
	"do_Label_title2.text":"title2",
	"starList2.tag":"feedbackScore2"
});

root.on("dataRefreshed", function(){
	var num = ["保洁服务","家电清洗","家居保养"].indexOf(do_Label_firstType.text);
	if(num>0){
		do_Label_firstType.fontColor = colorSerice[num];
		sericeIcon.source = iconSerice[num];
	};
	if (do_ALayout_base0.tag == "") {
		do_ALayout_base0.visible = false;
	} else {
		do_ALayout_base0.visible = true;
		var starList0 = ui("starList0");
		var listdata4Star0 = mm("do_ListData");
		starList0.bindItems(listdata4Star0);
		var feedbackScore = starList0.tag;
		var starListNew0 = [];
		for(var m=1;m<=5;m++){
			if(m <= feedbackScore){
				starListNew0.push({"starImg":"source://image/common/x_01.png"});
			}else{
				starListNew0.push({"starImg":"source://image/common/x_02.png"});
			}
		}
		listdata4Star0.addData(starListNew0);
		starList0.refreshItems();
	}
	if (do_ALayout_base1.tag == "") {
		do_ALayout_base1.visible = false;
	} else {
		do_ALayout_base1.visible = true;
		var starList1 = ui("starList1");
		var listdata4Star1 = mm("do_ListData");
		starList1.bindItems(listdata4Star1);
		var feedbackScore = starList1.tag;
		var starListNew1 = [];
		for(var m=1;m<=5;m++){
			if(m <= feedbackScore){
				starListNew1.push({"starImg":"source://image/common/x_01.png"});
			}else{
				starListNew1.push({"starImg":"source://image/common/x_02.png"});
			}
		}
		listdata4Star1.addData(starListNew1);
		starList1.refreshItems();
	}
	if (do_ALayout_base2.tag == "") {
		do_ALayout_base2.visible = false;
	} else {
		do_ALayout_base2.visible = true;
		var starList2 = ui("starList2");
		var listdata4Star2 = mm("do_ListData");
		starList2.bindItems(listdata4Star2);
		var feedbackScore = starList2.tag;
		var starListNew2 = [];
		for(var m=1;m<=5;m++){
			if(m <= feedbackScore){
				starListNew2.push({"starImg":"source://image/common/x_01.png"});
			}else{
				starListNew2.push({"starImg":"source://image/common/x_02.png"});
			}
		}
		listdata4Star2.addData(starListNew2);
		starList2.refreshItems();
	}
});

do_ALayout_base0.on("touch", function(){
	common.open("source://view/homemaking/detail/detail.ui",{id:do_ALayout_base0.tag});
});
do_ALayout_base1.on("touch", function(){
	common.open("source://view/homemaking/detail/detail.ui",{id:do_ALayout_base1.tag});
});
do_ALayout_base2.on("touch", function(){
	common.open("source://view/homemaking/detail/detail.ui",{id:do_ALayout_base2.tag});
});